package com.flx.sentinel.handler;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.flx.common.utils.result.ResultResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author Fenglixiong
 * @Create 2022/4/23 18:57
 * @Description
 **/
@Slf4j
public class DefaultBlockHandler {

    /**
     * 限流处理器，参数和返回值一定要对上比如参数name，返回值ResultResponse，不然匹配不到
     * @return
     */
    public static ResultResponse helloBlockHandler(String name, BlockException e){
        log.info("【全局流控】您访问过于频繁，请稍后再试一下哦,error = {}",e.toString());
        return ResultResponse.error("您访问过于频繁，请稍后再试一下哦！param = "+name);
    }

}
